<?php defined('InShopNC') or exit('Access Invalid!');?>

<div class="tabmenu">
  <?php include template('layout/submenu');?>
  <a class="ncbtn ncbtn-mint" href="javascript:void(0);" ><i class="icon-plus-sign"></i>添加广告</a>

</div>

<?php if ($output['isOwnShop']) { ?>
<div class="alert alert-block mt10">
  <ul>
    <li>1、被推荐专题广告将在该铂金专题商品列表上方随机出现。</li>
    <?php if (C('promotion_ztadv_goods_sum') != 0) {?>
    <li>2、您最多可以推荐<?php echo C('promotion_ztadv_goods_sum');?>个广告。</li>
    <?php }?>
  </ul>
</div>
<?php } else { ?>
<!-- 有可用套餐，发布活动 -->
<div class="alert alert-block mt10">
<?php if (empty($output['booth_quota']) || $output['booth_quota']['booth_state'] == 0) {?>
  <strong>你还没有购买套餐或套餐已经过期，请购买或续费套餐。</strong>
<?php } else {?>
  <strong>套餐过期时间<?php echo $lang['nc_colon'];?></strong> <strong style=" color:#F00;"><?php echo date('Y-m-d H:i:s',$output['booth_quota']['booth_quota_endtime']);?></strong>
<?php }?>
  <ul>
    <li>1、点击购买套餐或续费套餐可以购买或续费套餐</li>
    <li>2、<strong style="color: red">相关费用会在店铺的账期结算中扣除</strong>。</li>
    <li>3、被推荐商品将在该商品所在的分类及其上级分类的商品列表左侧随机出现。</li>
    <?php if (C('promotion_ztadv_goods_sum') != 0) {?>
    <li>4、您最多可以推荐<?php echo C('promotion_ztadv_goods_sum');?>个广告。</li>
    <?php }?>
  </ul>
</div>
<?php } ?>

<?php if ($output['isOwnShop'] || (!empty($output['booth_quota']) && $output['booth_quota']['booth_state'] == 1)) { ?>
<!-- 商品搜索 -->
<table class="ncsc-default-table">
  <thead>
    <tr>
      <th class="w180">广告图片</th>
      <th class="w80">开始时间</th>
      <th class="w80">结束时间</th>
      <th class="w40">位置</th>
      <th class="w100">状态</th>
      <th class="w110"><?php echo $lang['nc_handle'];?></th>
    </tr>
  </thead>

  <tbody>
    <?php if(!empty($output['adv_list'])) {
      $State = array('1'=>'正常','2'=>'待审核','0'=>'已取消');
      $Place = array('0'=>'', '1'=>'顶部','2'=>'右边');
      ?>
    <?php foreach($output['adv_list'] as $key=>$val){?>
    <tr class="bd-line">
      <td><div><a href="<?php echo $val['adv_url'];?>" target="black"><img src="<?php echo BASE_SITE_URL.DS.DIR_UPLOAD.DS.ATTACH_ADV.DS.$val['adv_image'];?>" width="280"/></a></div></td>
      <td><?php echo date('Y-m-d H:i',$val['start_time']);?></td>
      <td><?php echo date('Y-m-d H:i',$val['end_time']);?></td>
      <td><?php echo $Place[$val['place']];?>
      <td><?php echo $State[$val['state']];?></td>
      <td>
        <span><a class="btn-grapefruit" href='javascript:void(0);' nctype="del_choosed" data-param="{gid:<?php echo $val['adv_id'];?>}"><i class="icon-trash"></i><p><?php echo $lang['nc_del'];?></p></a></span></td>
    </tr>
    <?php }?>
    <?php } ?>
  </tbody>
</table>
<?php }else{?>
<!-- 没有可用套餐，购买 -->
<table class="ncsc-default-table ncsc-promotion-buy">
  <tbody>
    <tr>
      <td colspan="20" class="norecord"><div class="no-promotion"><i class="zw"></i><span>您还没有购买套餐，或该促销活动已经关闭。<br />请先购买套餐，再查看活动列表。</span></div></td>
    </tr>
  </tbody>
</table>
<?php }?>
<script>
$(function(){
    $(".ncbtn-mint").click(function() {
        ajax_form('ajax_promotion', '新增预售商品广告', 'index.php?act=store_promotion_booth&op=add_yszt_adv',640);
    });

  $('a[nctype="del_choosed"]').click(function(){
    $this = $(this);
    _url = '<?php echo urlShop('store_promotion_booth', 'del_ztadv');?>';
    eval('var data_str = ' + $(this).attr('data-param'));
    $.getJSON(_url, {gid : data_str.gid}, function(data){
      if (data.result == 'true') {
        $this.parents('tr:first').fadeOut("slow",function(){
          $(this).remove();
        });
      } else {
        showError(data.msg);
      }
    });
  });

});
</script>